all : bin

x86asm : clean
	$(PYTHON) $(PYSRCDIR)pypl0_main.py x86asm -o $(ASMDIR)expression.asm $(PL0SRCDIR)expression.pl0
	$(PYTHON) $(PYSRCDIR)pypl0_main.py x86asm -o $(ASMDIR)factorial.asm  $(PL0SRCDIR)factorial.pl0
	$(PYTHON) $(PYSRCDIR)pypl0_main.py x86asm -o $(ASMDIR)gcd.asm        $(PL0SRCDIR)gcd.pl0
	$(PYTHON) $(PYSRCDIR)pypl0_main.py x86asm -o $(ASMDIR)minimal.asm    $(PL0SRCDIR)minimal.pl0
	$(PYTHON) $(PYSRCDIR)pypl0_main.py x86asm -o $(ASMDIR)square.asm     $(PL0SRCDIR)square.pl0

obj : x86asm
	$(AS) $(ASFLAGS) -o $(OBJDIR)expression.o $(ASMDIR)expression.asm
	$(AS) $(ASFLAGS) -o $(OBJDIR)factorial.o  $(ASMDIR)factorial.asm
	$(AS) $(ASFLAGS) -o $(OBJDIR)gcd.o        $(ASMDIR)gcd.asm
	$(AS) $(ASFLAGS) -o $(OBJDIR)minimal.o    $(ASMDIR)minimal.asm
	$(AS) $(ASFLAGS) -o $(OBJDIR)square.o     $(ASMDIR)square.asm

libobj:
	$(AS) $(ASFLAGS) -o $(ASMLIB) lib/x86asm/asm_io.asm

bin : obj libobj
	$(CC) -o $(BINDIR)expression $(OBJDIR)expression.o $(ASMLIB)
	$(CC) -o $(BINDIR)factorial  $(OBJDIR)factorial.o $(ASMLIB)
	$(CC) -o $(BINDIR)gcd        $(OBJDIR)gcd.o       $(ASMLIB)
	$(CC) -o $(BINDIR)minimal    $(OBJDIR)minimal.o   $(ASMLIB)
	$(CC) -o $(BINDIR)square     $(OBJDIR)square.o    $(ASMLIB)

clean :
	rm -f $(PYSRCDIR)*.pyc $(ASMDIR)*.asm $(OBJDIR)*.o $(BINDIR)* $(ASMLIB)

